//
//  WLSocketManager.h
//  WanLian
//
//  Created by muzhuang on 2018/11/2.
//  Copyright © 2018年 wanlian. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GCDAsyncSocket.h"
#import "WLSocketModel.h"
NS_ASSUME_NONNULL_BEGIN

@protocol RouterSocketDelegate <NSObject>

@required

//接收消息代理
- (void)didReceiveMessage:(WLSocketModel *)msgModel withTag:(long)tag;

@optional
//发送消息超时代理
- (void)sendMessageTimeOutWithTag:(long)tag;

@end
typedef NS_ENUM(NSUInteger, WLConnectionState) {
    WLConnectionStateDisconnected,
    WLConnectionStateConnecting,
//    WLConnectionStateConnected,
    WLConnectionStateRouter,
    WLConnectionStateRemote,
    WLConnectionStateDisconnectedCanBeReconnect
};

@interface WLSocketManager : NSObject

extern NSString *const HOST_ROUTER;
extern NSString *const HOST_REMOTE;

//初始化
@property (strong , nonatomic) GCDAsyncSocket *routerSocket;
//socket注册状态
@property (nonatomic, assign) BOOL isRegistered;
//socket连接状态
@property (nonatomic, assign) WLConnectionState socketState;

//@property (strong, nonatomic)GCDAsyncSocket * mySocket;

+ (WLSocketManager *)sharedSocketManager;

- (void)connectServerHost;
- (void)connectRemoteServerHost;

- (void)userManualdisconnect;
- (void)disconnect;

- (void)routerSocketRegister;

- (void)addDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
- (void)removeDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
//添加代理
- (void)addDelegate:(id<RouterSocketDelegate>)delegate;// delegateQueue:(dispatch_queue_t)queue;
//移除代理
- (void)removeDelegate:(id<RouterSocketDelegate>)delegate;

- (void)sendMessage:(NSDictionary *)dictMsg timeOut:(NSUInteger)timeOut tag:(long)tag;//(WLSocketModel *)msgModel;

@end

NS_ASSUME_NONNULL_END
